package com.anxin.act.model.entity;

import com.alibaba.fastjson.JSONObject;
import com.anxin.common.utils.IdGen;
import com.anxin.common.utils.sys.UserUtils;
import com.anxin.sys.system.entity.SysUser;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.anxin.framework.aspectj.lang.annotation.Excel;
import com.anxin.framework.web.entity.BaseEntity;

import java.util.Date;

/**
 * 工作流审批人配置对象 wf_act_approver
 *
 * @author jbs
 * @date 2020-03-18
 */
public class WfActApprover extends BaseEntity<WfActApprover>{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private String id;

    /** 配置的审批人类型 */
    @Excel(name = "配置的审批人类型")
    private String type;

    /** 审批人标识 */
    @Excel(name = "审批人标识")
    private String approver;

    /** 工作流节点的唯一标识 */
    @Excel(name = "工作流节点的唯一标识")
    private String actUuid;

    //模型唯一标识
    private String modelId;


    /**
     * 配置类型 approval:审批人   ccUsers:抄送用户
     */
    private String configType;


    public  WfActApprover(){}

    public  WfActApprover(String actUuid,String modelId, String type, String approver,String configType){
        this.id= IdGen.uuid();
        this.type=type;
        this.actUuid=actUuid;
        this.approver=approver;
        this.modelId=modelId;
        this.configType = configType;

        SysUser user = UserUtils.getUser();
        Date time = new Date(System.currentTimeMillis());
        super.setCreateBy(user);
        super.setCreateTime(time);
        super.setUpdateBy(user);
        super.setUpdateTime(time);
    }

    public WfActApprover(JSONObject jsonObject){
        this.type = jsonObject.getString("type");
        this.configType = jsonObject.getString("configType");
        this.approver = jsonObject.getString("approver");
        this.actUuid = jsonObject.getString("actUuid");
        this.modelId = jsonObject.getString("modelId");

    }

    public String getConfigType() {
        return configType;
    }

    public void setConfigType(String configType) {
        this.configType = configType;
    }

    public void setId(String id){
        this.id = id;
    }

    public String getId(){
        return id;
    }
    public void setType(String type){
        this.type = type;
    }

    public String getType(){
        return type;
    }
    public void setApprover(String approver){
        this.approver = approver;
    }

    public String getApprover(){
        return approver;
    }
    public void setActUuid(String actUuid){
        this.actUuid = actUuid;
    }

    public String getActUuid(){
        return actUuid;
    }
    public String getModelId() {
        return modelId;
    }

    public void setModelId(String modelId) {
        this.modelId = modelId;
    }


    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("type", getType())
            .append("approver", getApprover())
            .append("actUuid", getActUuid())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .toString();
    }



    /**
     * 将数据转换为JSON
     * @return
     */
    public JSONObject toJson(){
        JSONObject json = new JSONObject();
        json.put("id", this.id);
        json.put("type", this.type);
        json.put("configType",this.configType);
        json.put("approver", this.approver);
        json.put("actUuid", this.actUuid);
        json.put("modelId",this.modelId);
        return json;
    }
}
